import { useStore } from "vuex";
import { toRef, watch } from "vue";

export default function (audio) {
    const store = useStore();
    //  当 音乐src 改变时, 重新加载音频以及让歌词重新开始  
    const pre = toRef(store.state.PlaySong, "presentSong");
    watch(pre, () => {
        audio.value.load();
        // 播放
        store.commit("PlaySong/PlaySong", false);
        //  让歌词重新开始
        store.commit("SongLyric/changeLyricProgressTime", 0);

    })
    return {
        pre
    }
}